//
//  ViewController.m
//  2.18(afternoon)
//
//  Created by student on 16/2/18.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UIAlertViewDelegate,UIActionSheetDelegate>

@end

@implementation ViewController
- (IBAction)backTap:(id)sender {
    [self.textField resignFirstResponder];
    [self.textField2 resignFirstResponder];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



- (IBAction)Segementchanged:(UISegmentedControl *)sender
{
    if (sender.selectedSegmentIndex == 0) {
        self.LeftSwitch.hidden = NO;
        self.RightSwitch.hidden = NO;
        self.dosomethingButtonPressed.hidden = YES;
    }
    else
    {
        self.LeftSwitch.hidden = YES;
        self.RightSwitch.hidden = YES;
        self.dosomethingButtonPressed.hidden = NO;
    }
}

- (IBAction)LeftSwitch:(UISwitch *)sender
{
    // 开关控件的主要属性:
    // 开关的当前开关状态 on属性
    BOOL open = sender.on;
    
    // 设置状态，并是否要带上动画
    [self.LeftSwitch setOn:open animated:YES];
    [self.RightSwitch setOn:open animated:NO];
}

- (IBAction)SliderValue:(UISlider *)sender
{
    int value = sender.value;
    // 把滑动条的值显示到Label上
    self.SliderValueLabel.text = [NSString stringWithFormat:@"%i",value];
}

- (IBAction)dosomethingButtonPressed:(UIButton *)sender
{
            UIActionSheet *sheet =[[UIActionSheet alloc] initWithTitle:@"你确定吗？" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"是的我确定！" otherButtonTitles: nil];
        [sheet showInView:self.view];
    }
    
    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
    {
       
        if (buttonIndex == actionSheet.destructiveButtonIndex)
        {
            NSString *String = [self.textField.text stringByAppendingString:@"小兄弟，爸爸罩你!"];
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"某些事项被执行了！" message:(@"%@",String) delegate:self cancelButtonTitle:@"GoodJob ,Boy!" otherButtonTitles:nil];
            [alertView show];

        }
        else if (buttonIndex == actionSheet.cancelButtonIndex)
        {
            
        }
        
    }


@end
